<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2018/11/29
 * Time: 2:35 PM
 */

namespace app\shop\model;

/**
 * Class GoodsSpec
 * @package app\shop\model
 * @OA\Schema(schema="GoodsSpec", description="商品规格", type="object",
 *   @OA\Property(property="spec_id", description="规格ID", type="integer", format="int32"),
 *   @OA\Property(property="spec_name", description="规格名称", type="string", ),
 *   @OA\Property(property="show_type", description="规格展示方式", type="string", enum={"word", "color", "image"}, default="word" ),
 *   @OA\Property(property="values", description="规格值", type="array", @OA\Items(ref="#/components/schemas/GoodsSpecValue"), ),
 * )
 */
class GoodsSpec extends \ShopModel
{
    protected $table = 'sh_goods_spec';

    public function values()
    {
        return $this->hasMany('GoodsSpecValue', 'spec_id')
            ->field('value_id, value_name')
            ->where('is_hidden', 0)
            ->order('sort_order', 'desc');
    }
}